package cn.bughub.controller;


import cn.bughub.model.vo.user.UserDetailResponseVo;
import cn.bughub.util.JsonUtil;
import cn.bughub.util.ResultResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户控制器
 *
 * @author zwj
 * @date 2024-09-25
 */
@RestController
@RequestMapping("/user")
@RequiredArgsConstructor
public class UserController {
    
    @GetMapping("/detail")
    public ResultResponse<UserDetailResponseVo> detail() {
        String userDetailJson = """
                {
                        "id": 1,
                        "username": "admin",
                        "enable": true,
                        "createTime": "2023-11-18T08:18:59.150Z",
                        "updateTime": "2023-11-18T08:18:59.150Z",
                        "profile": {
                            "id": 1,
                            "nickName": "Admin",
                            "gender": null,
                            "avatar": "https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif?imageView2/1/w/80/h/80",
                            "address": null,
                            "email": null,
                            "userId": 1
                        },
                        "roles": [
                            {
                                "id": 1,
                                "code": "SUPER_ADMIN",
                                "name": "超级管理员",
                                "enable": true
                            },
                            {
                                "id": 2,
                                "code": "ROLE_QA",
                                "name": "质检员",
                                "enable": true
                            }
                        ],
                        "currentRole": {
                            "id": 1,
                            "code": "SUPER_ADMIN",
                            "name": "超级管理员",
                            "enable": true
                        }
                    }
                """;
        UserDetailResponseVo vo = JsonUtil.parseObject(userDetailJson, UserDetailResponseVo.class);
        return ResultResponse.success(vo);
    }
}
